{include file="pageheader_erp.htm"}

{insert_scripts files="../js/jquery.1.3.2.js"}

<style type="text/css">
	#outside_container
	{
		width:100%;
		border:none;
		overflow:hidden;
		text-align:center;
		padding:10px;
		background-color:#F4FAFB;
	}
	#inner_container
	{
		width:50%;
		border:1px solid #DDD;
		overflow:hidden;
		text-align:left;
		background-color:#DDEEF2;
		margin:0 auto;
	}

	
	#inner_container table tr td
	{
		padding:6px;
		font-weight:bold;
		background-color:#FFF;
	}
	
	.tb_lable
	{
		padding-left:20px;
		
	}

</style>


 <!-- start goods list -->
<div class="main-div">
	<div id="outside_container">
		<div id="inner_container">
			<form name="add_supplier"  id="add_supplier"  action="javascript:;"  onsubmit="javascript:addSupplier(this);" method="post">
				<table>
					<tr>
						<td width="100"><span class="tb_lable">{$lang.erp_supplier_code}：</span></td>
						<td><input name="supplier_code"  id="supplier_code" type="text" value="{if $act eq 'add'}{$supplier_code}{else}{$supplier_info.code}{/if}" style="display:block;" disabled="disabled" /></td>
						<td><span>&nbsp;</span></td>
					</tr>
					<tr>
						<td><span class="tb_lable">{$lang.erp_supplier_name}：</span></td>
						<td><input name="supplier_name" id="supplier_name" type="text" value="{$supplier_info.name}" size="40" /></td>
						<td><span style="color:red;font-weight:normal;">{$lang.erp_required_item}</span></td>
					</tr>
					<tr>
						<td><span class="tb_lable">{$lang.erp_supplier_address}：</span></td>
						<td><input name="supplier_address" id="supplier_address" type="text" value="{$supplier_info.address}" size="40" /></td>
						<td><span>&nbsp;</span></td>
					</tr>
					<tr>
						<td><span class="tb_lable">{$lang.erp_supplier_contact}：</span></td>
						<td><input name="supplier_contact" id="supplier_contact" type="text" value="{$supplier_info.contact}" /></td>
						<td><span>&nbsp;</span></td>
					</tr>
					<tr>
						<td><span class="tb_lable">{$lang.erp_supplier_tel}：</span></td>
						<td><input name="supplier_tel" id="supplier_tel" type="text" value="{$supplier_info.tel}" /></td>
						<td><span>&nbsp;</span></td>
					</tr>
					<tr>
						<td><span class="tb_lable">{$lang.erp_supplier_fax}：</span></td>
						<td><input name="supplier_fax" id="supplier_fax" type="text" value="{$supplier_info.fax}" /></td>
						<td><span>&nbsp;</span></td>
					</tr>
					<tr>
						<td><span class="tb_lable">{$lang.erp_supplier_group_name}：</span></td>
						<td>
							{if $supplier_group}
							<select id="supplier_group_id">
								{foreach from=$supplier_group item=group}
									<option value='{$group.group_id}' {if $group.group_id eq $supplier_info.supplier_group_id}selected='selected'{/if}>{$group.group_name}</option>
								{/foreach}
							</select>
							{/if}	
						</td>
						<td><span>&nbsp;</span></td>
					</tr>	
					
					<tr>
						<td><span class="tb_lable">{$lang.erp_admin}：</span></td>
						<td>
							{if $admins}
							<select id="admin" name="admin" >
								{foreach from=$admins item=admin}
									<option value='{$admin.user_id}' {if $supplier_info.admin_id eq $admin.user_id}selected='selected'{/if}>{$admin.user_name}</option>
								{/foreach}
							</select>
							{/if}
						</td>
						<td><span>&nbsp;</span></td>
					</tr>									
					<tr>
						<td><span class="tb_lable">{$lang.erp_is_valid}：</span></td>
						<td>
							<select id="is_valid" name="is_valid" >
									<option value='0' {if $supplier_info.is_valid eq 0}selected="selected"{/if} >{$lang.no}</option>
									<option value='1' {if $supplier_info.is_valid eq 1}selected="selected"{/if}>{$lang.yes}</option>
							</select>
						</td>
						<td><span>&nbsp;</span></td>
					</tr>				
					<tr><td  colspan="3" align="center"><input type="image" src="./images/submit.gif" style="cursor:pointer;" /></td></tr>																									
				</table>
				<input id="supplier_id" value="{$supplier_info.supplier_id}" style="display:none;">
				
			</form>
		</div>
	</div>
</div>
<!-- end goods list -->

{literal}
<script language="JavaScript">
   
   function addSupplierResponse(res){
   	 window.document.location="./erp_supplier.php?act=list";
   }
    function addSupplier()
	{
		var new_supplier=new Object();
		new_supplier['supplier_id']=$("#supplier_id").attr('value');
		
		new_supplier['code']=$("#supplier_code").attr('value');
		new_supplier['name']=$("#supplier_name").attr('value');
		new_supplier['address']=$("#supplier_address").attr('value');
		new_supplier['contact']=$("#supplier_contact").attr('value');
		new_supplier['tel']=$("#supplier_tel").attr('value');
		new_supplier['fax']=$("#supplier_fax").attr('value');
		new_supplier['supplier_group_id']=$("#supplier_group_id").attr('value');
		new_supplier['admin_id']=$("#admin").attr('value');
		new_supplier['is_valid']=$("#is_valid").attr('value');

		if(new_supplier['supplier_id']=="")
		{
			new_supplier['supplier_id']='EMPTY';
		}	
		if(new_supplier['code']=="")
		{
			alert('{$lang.erp_supplier_code_required}');
			return;
		}		
		if(new_supplier['name']=="")
		{
			alert('{$lang.erp_supplier_name_required}');
			return;
		}
		
		if(new_supplier['address']=="")
		{
			new_supplier['address']='EMPTY';
		}
		if(new_supplier['contact']=="")
		{
			new_supplier['contact']='EMPTY';
		}		
		if(new_supplier['tel']=="")
		{
			new_supplier['tel']='EMPTY';
		}		
		if(new_supplier['fax']=="")
		{
			new_supplier['fax']='EMPTY';
		}		
		Ajax.call('erp_supplier.php?act=save_supplier', 'new_supplier=' + JSON.stringify(new_supplier), addSupplierResponse, 'POST', 'JSON');
		
		}   
</script>
{/literal}
{include file="pagefooter.htm"}

